<template>
  <view :style="themeColor">
    <view class="page">
      <view class="flex benben-position-layout flex flex-wrap align-center addFollow_flex_0"
        :style="{height:(88+StatusBarRpx)+'rpx',paddingTop:StatusBarRpx+'rpx', }">
        <view class='flex flex-wrap align-center justify-between flex-sub addFollow_fd0_0'>
          <view class='flex flex-wrap align-center addFollow_fd0_0_c0' @tap.stop="handleJumpDiy" data-type="back"
            data-url="1">
            <text class='fu-iconfont2  addFollow_fd0_0_c0_c0'>&#xE794;</text>
          </view>
          <view class='flex flex-wrap align-stretch justify-center'>
            <text class='addFollow_fd0_0_c1_c0'>新增关注</text>
          </view>
          <view class='flex flex-wrap align-center justify-end addFollow_fd0_0_c0'>
          </view>
        </view>

      </view>
      <view :style="{height: (88+StatusBarRpx)+'rpx'}"></view>
      <!---flex布局flex布局开始-->
      <view class="flex flex-direction flex-wrap align-stretch benben-flex-layout addFollow_flex_1">
        <template v-for='(item,key0) in dynamicList'>
          <view class='flex flex-wrap align-start addFollow_fd1_0' :key='key0' @click.stop="goNato(item)">
            <view class='addFollow_fd1_0_c0' @click.stop="goUserHome(item)">
              <image mode="aspectFill" :src='item.avatar'></image>
              <view class="dian" v-if="item.is_read==0"></view>
            </view>
            <!-- <image class='addFollow_fd1_0_c0' mode="aspectFill" :src='item.avatar'></image> -->
            <view class='flex flex-wrap align-center justify-between flex-sub addFollow_fd1_0_c1'>
              <view class='flex flex-direction flex-wrap align-start flex-sub'>
                <view class='flex flex-wrap align-center'>
                  <text class='addFollow_fd1_0_c1_c0_c0_c0'>{{item.nickname}}</text>
                </view>
                <view class='flex flex-wrap align-center addFollow_fd1_0_c1_c0_c1'>
                  <text class='addFollow_fd1_0_c1_c0_c1_c0'>{{item.msg}}</text>
                  <text class='addFollow_fd1_0_c1_c0_c1_c1'>{{item.create_time}}</text>
                </view>
              </view>
              <button class='addFollow_fd1_0_c1_c1' @tap.stop="followCancelFunc(item,item.is_follow)"
                v-if=" item.is_follow==0">关注</button><button class='addFollow_fd1_0_c1_c1_1'
                @tap.stop="followCancelFunc(item,item.is_follow)" v-if=" item.is_follow=='2'">互相关注</button>
              <button class='addFollow_fd1_0_c1_c1_1' @tap.stop="followCancelFunc(item,item.is_follow)"
                v-if=" item.is_follow=='1'">已关注</button>
            </view>
          </view>
        </template>
        <fu-empty :pagingListLoadedAll="pagingListLoadedAll" :pagingListNoListData="pagingListNoListData"
          :listDataLength="listDataLength" :isLoadInit="isLoadInit"></fu-empty>
      </view>

      <!---flex布局flex布局结束-->


    </view>
  </view>
</template>
<script>
  import pagingList from '@/common/mixin/paging_list.js';
  import {
    validate
  } from '@/common/utils/validate.js'

  export default {
    components: {},
    mixins: [pagingList],

    data() {
      return {
        "minixPagingListsApi": "",
        "pageingListApiMethod": "",
        "allowOnloadGetList": false,
        "state": "1",
        "dynamicList": []
      };
    },
    computed: {
      themeColor() {
        return this.$store.getters.themeColor
      },
      isLogin() {
        return this.$store.state.token == '' ? false : true;
      },
      userInfo: {
        get() {
          return this.$store.state.userInfo.userinfo
        },
        set() {
          this.$store.commit('updateUserInfo', value)
        },
      },
    },
    watch: {},
    onLoad(options) {

    },
    onUnload() {

    },
    onReady() {

    },
    onShow() {
      this.getListFunc()
    },
    onHide() {

    },
    onResize() {

    },
    onPullDownRefresh() {
      this.getListFunc()
    },
    onReachBottom(e) {

    },
    onPageScroll(e) {

    },
    methods: {
      goUserHome(item) {
        uni.navigateTo({
          url: `/pages/wode/myFans/userHome?uid=${item.user_id_2}`
        })
      },
      //获取动态关注列表
      getListFunc() {
        this.minixPagingListsApi = global.apiUrls.post657ab4fa913be;
        this.pageingListApiMethod = 'post';
        this.allowOnloadGetList = false;
        this.pagingListPostDataContent = {
          user_id: this.userInfo.id
        }
        this.listData = [];
        this.dynamicList = this.listData;
        this.pagingListToggle();

      },
      //关注取消
      async followCancelFunc(item, follw) {
        //请求方法
        //数据验证
        this.$api.post(global.apiUrls.post65b9f06edc3cc, {
          aid: item.aid
        })
        let data657822ffc15db = await this.$api.post(global.apiUrls.post657822ffc15db, {
          user_id_2: item.user_id_2,
          action: follw == 0 ? 1 : 0
        });

        if (data657822ffc15db.data.code != 1) {
          this.$message.info(data657822ffc15db.data.msg);
          return
        }
        this.getListFunc()


      },
      goNato(item) {
        this.$api.post(global.apiUrls.post65b9f06edc3cc, {
          aid: item.aid
        }).then(res => {
          if (res.data.code == 1) {
            this.getListFunc()
          }
        })

      },
      pagingListPostData() {
        return this.pagingListPostDataContent
      }
    }
  };
</script>
<style lang="scss" scoped>
  .page {
    width: 100vw;
    overflow-x: hidden;
    min-height: calc(100vh - var(--window-bottom));
    background: rgba(255, 255, 255, 1);
    background-size: 100% auto;
  }

  .addFollow_flex_0 {
    border-bottom: 1px solid rgba(238, 238, 238, 1);
    background: #fff;
    width: 750rpx;
    height: 88rpx;
    overflow: hidden;
    z-index: 10;
    top: 0rpx;
    background-size: 100% auto !important;
  }

  .addFollow_fd0_0_c1_c0 {
    font-size: 36rpx;
    font-weight: 700;
    color: #333333;
    line-height: 50rpx;
  }

  .addFollow_fd0_0_c0_c0 {
    font-size: 36rpx;
    color: #333;
  }

  .addFollow_fd0_0_c0 {
    width: 120rpx;
  }

  .addFollow_fd0_0 {
    padding: 0rpx 32rpx 0rpx 32rpx;
  }

  .addFollow_flex_1 {
    padding: 32rpx 32rpx 0rpx 32rpx;
  }

  .addFollow_fd1_0_c1_c1_1 {
    border: 1px solid rgba(153, 153, 153, 1);
    background: rgba(255, 255, 255, 1);
    border-radius: 33rpx 33rpx 33rpx 33rpx;
    width: 124rpx;
    line-height: 56rpx;
    font-size: 24rpx;
    color: rgba(153, 153, 153, 1);
  }

  .addFollow_fd1_0_c1_c1 {
    background: rgba(100, 80, 235, 1);
    border-radius: 33rpx 33rpx 33rpx 33rpx;
    width: 124rpx;
    line-height: 56rpx;
    font-size: 24rpx;
    color: #fff;
  }

  .addFollow_fd1_0_c1_c0_c1_c1 {
    margin: 0rpx 0rpx 0rpx 17rpx;
    color: #999999;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .addFollow_fd1_0_c1_c0_c1_c0 {
    color: #999999;
    font-size: 24rpx;
    font-weight: 400;
    line-height: 32rpx;
  }

  .addFollow_fd1_0_c1_c0_c1 {
    margin: 16rpx 0rpx 0rpx 0rpx;
  }

  .addFollow_fd1_0_c1_c0_c0_c0 {
    color: #333333;
    font-size: 28rpx;
    font-weight: 700;
    line-height: 28rpx;
  }

  .addFollow_fd1_0_c1 {
    border-bottom: 1px solid #eee;
    padding: 0rpx 0rpx 32rpx 0rpx;
  }

  .addFollow_fd1_0_c0 {
    width: 90rpx;
    height: 90rpx;
    border-radius: 50%;
    margin: 0rpx 24rpx 0rpx 0rpx;
    position: relative;

    image {
      width: 90rpx;
      height: 90rpx;
      border-radius: 50%;
    }

    .dian {
      position: absolute;
      right: 0;
      top: 0;
      width: 16rpx;
      height: 16rpx;
      background: red;

      border-radius: 50%;
      z-index: 9
    }
  }

  .addFollow_fd1_0 {
    margin: 0rpx 0rpx 32rpx 0rpx;
  }
</style>
